package cn.tedu._03vehicle.base.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;

import java.time.LocalTime;

public class usetime implements HandlerInterceptor
{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        LocalTime time = LocalTime.now();
        int hour = time.getHour();
        if (hour < 11 || hour > 18)
        {
//            throw new RuntimeException("不在营业时间");
            response.sendRedirect("/error.html");
        }
        return true;
    }
}
